class ExportController < ApplicationController
  include ApplicationHelper
  include UsersHelper
  include ExportHelper
  def excel
    columns = ["Name","Company","Department","Job Title","Location","Phone","Cell Phone","E-Mail","Address","Skype","Wiki Space"]
    data = getFirstEmployees.find(:only => [:Name, :BusinessUnit, :Department, :JobTitle, :Office, :PhoneWork, :PhoneCell, :EMail,
        :OfficeAddress, :SkypeName, :WikiSpaceURL], :conditions => getSQLCondition(params))
    csv_string = export_to_excel data, columns
    send_data csv_string, :type => "text/plain", :filename=>"entries.csv", :disposition => 'attachment'

  end

  def vcf
    employee = getFirstEmployees.find({:only => [:EmployeeNumber,:Name,:BusinessUnit,:JobTitle,:PhoneWork,:PhoneCell,:OfficeAddress,:City,
          :Country,:State,:PostalCode,:EMail], :conditions => ["EmployeeNumber = ?", params[:id]]})
    vcf_string = employee ? export_to_vcf(employee.first) : nil
    send_data vcf_string, :type => "text/plain", :filename=>"#{employee ? employee.first.Name : "Not Found"}.vcf", :disposition => 'attachment'
  end

end
